IF EXISTS (
	SELECT SPECIFIC_NAME 
	FROM INFORMATION_SCHEMA.ROUTINES 
	WHERE SPECIFIC_SCHEMA = N'testing'
		AND SPECIFIC_NAME = N'prc_GetQuestionsList' 
)
	BEGIN
		DROP PROCEDURE testing.prc_GetQuestionsList
		PRINT 'Dropping testing.prc_GetQuestionsList'
	END
GO

/*-------------------------------------------------------------------------------------
** Name:	prc_GetQuestionsList
** Purpose:	get questions list belong to a question group
** 
** ------------------------------------------------------------------------------------
** Input Parameters: 
** @QuestionGroupId
** 
** ------------------------------------------------------------------------------------
** Usage
** EXEC testing.prc_GetQuestionsList 1
**
** ------------------------------------------------------------------------------------
** Author:    Hau
** Date:      2012-08-05
** Database:  SIVN_OnlineTestingEngine
**
** ------------------------------------------------------------------------------------
** Modifications:
** 2012-08-05	Hau		Create
** ----------------------------------------------------------------------------------*/

CREATE PROCEDURE [testing].[prc_GetQuestionsList]
@QuestionGroupId int
AS
BEGIN
	SET NOCOUNT ON;
	
	SELECT q.*
	FROM testing.Question q join testing.QuestionGroupDetail qgd on q.Id = qgd.QuestionId
	where qgd.QuestionGroupId = @QuestionGroupId
END

PRINT 'Created [testing].[prc_GetQuestionsList]'
GO